/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package wwcontrolserver.ifk;

import com.phidgets.PhidgetException;
import com.phidgets.event.AttachListener;
import com.phidgets.event.DetachListener;
import com.phidgets.event.InputChangeListener;
import com.phidgets.event.OutputChangeListener;
import com.phidgets.event.SensorChangeListener;
import java.util.ArrayList;
import wwcontrolserver.datarecorders.AbstractDataRecorder;
import wwcontrolserver.datarecorders.WWControlServerLogger;

/**
 *
 * @author Michael Ferry
 */
public class DigitalOutputIFK extends AbstractIFK {
    
    public DigitalOutputIFK(int ifkSerial, String ifkName, AttachListener AL, DetachListener DL) throws PhidgetException{
        super(ifkSerial, ifkName, AL, DL);
    }
    @Override
    public void RecordIFKState(WWControlServerLogger WWCSLog, ArrayList<AbstractDataRecorder> DataRecList) throws PhidgetException{
       if (ifk.isAttached()) {

        } else {
            for (AbstractDataRecorder DataRec : DataRecList) {
                DataRec.InsertSensorRecordNA(ifkSerial);
            }
        } 
    }
    public void SetOutputState(int ONUM, boolean state) throws PhidgetException {
        ifk.setOutputState(ONUM, state);
    }
    public boolean GetOutputState(int ONUM) throws PhidgetException{
        return ifk.getOutputState(ONUM);
    }

    @Override
    public void ExecuteDefaultAttach() throws PhidgetException {
    }
    
    @Override
    public void ExecuteDefaultDetach(){       
    }
    @Override
    public  void AddOutputChangeListener(OutputChangeListener OL){
        ifk.addOutputChangeListener(OL);
    }
    @Override
    public void AddInputChangeListener(InputChangeListener IL){
    }
    @Override
    public void AddSensorChangeListener(SensorChangeListener SL){
    }
}
